package com.leilei.service.impl;

import com.leilei.dao.ICommodityDao;
import com.leilei.dao.impl.CommodityDaoImpl;
import com.leilei.entity.Commodity;
import com.leilei.entity.Page;
import com.leilei.service.ICommodityService;

import java.util.List;

public class CommodityServiceImpl implements ICommodityService {

    private ICommodityDao commodityDao = new CommodityDaoImpl();

    @Override
    public List<Commodity> getCommodityInIndex(int type) {

        return commodityDao.selectCommodityInIndex(type);
    }

    @Override
    public List<Commodity> getCommodityBypage(int type, int page, int pageSize) {
        return commodityDao.selectCommodityByPage(type, page, pageSize);
    }

    @Override
    public Commodity getCommodityByPid(int pid) {

        return commodityDao.selectCommodityById(pid);
    }

    @Override
    public Commodity getCommodityCustom(int pid, int pvid, int pcid) {

        return commodityDao.selectCommodityCustom(pid, pvid, pcid);
    }

    @Override
    public List<Commodity> getCommodityByPage(Page page, int type) {

        return commodityDao.selectCommodityByPage(page, type);
    }

    @Override
    public int getCountByType(int type) {

        return commodityDao.selectCountByType(type);
    }

    @Override
    public boolean updateCommodity(Commodity commodity) {

        return commodityDao.updateCommodity(commodity) > 0;
    }

    @Override
    public boolean insertCommodity(Commodity commodity) {

        return commodityDao.insertCommodity(commodity) > 0;
    }

    @Override
    public List<Commodity> lunboCommodity() {

        return commodityDao.lunboCommodity();
    }

}
